from flask import Flask
from flask_cors import CORS
from extensions import init_plugs
import os

import sys

sys.path.append(os.path.split(os.path.abspath(os.path.dirname(__file__)))[0])

from config.config import config
from views import init_view

# 导入环境变量

app = Flask(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

# 引入数据库配置
app.config.from_object(config['development'])

# 注册各种插件
init_plugs(app)

# 注册路由
init_view(app)

app.app_context().push()

CORS(app, resources=r'/*')

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True)
